<template>
    <div class="container">
        <h1 style="text-align: center">合同页</h1>
        <el-descriptions title="合同信息" :column="1">
            <el-descriptions-item label="合同编码">{{pageData.barCode}}</el-descriptions-item>
            <el-descriptions-item label="类型">{{pageData.type===1 ? '省内':'省外'}}</el-descriptions-item>
        </el-descriptions>
        <hr/>
        <el-descriptions title="零售商信息" :column="1">
            <el-descriptions-item label="姓名">{{retailer.name}}</el-descriptions-item>
            <el-descriptions-item label="联系电话">{{retailer.telephone}}</el-descriptions-item>
            <el-descriptions-item label="送货地址">{{retailer.address}}</el-descriptions-item>
        </el-descriptions>
        <hr/>
        <h2>货物信息</h2>
        <el-table
                border
                :data="tableData"
                style="width: 100%">
            <el-table-column
                    align="center"
                    prop="name"
                    label="名称"
                    width="100">
            </el-table-column>
            <el-table-column
                    align="center"
                    prop="price"
                    label="价格"
                    width="100">
            </el-table-column>
            <el-table-column
                    align="center"
                    prop="locality"
                    width="200"
                    label="产地">
            </el-table-column>
            <el-table-column
                    align="center"
                    prop="accessoryList"
                    width="210"
                    label="附属品">
                <template slot-scope="scope">
                    <div v-if="scope.row.accessoryList.length > 0">
                        <div v-for="(item,index) in scope.row.accessoryList" :key="index">
                            {{item.name }}: {{  item.price}}元
                        </div>
                    </div>
                    <div v-else>
                        暂无附属品
                    </div>

                </template>
            </el-table-column>
            <el-table-column
                    align="center"
                    prop="number"
                    width="248"
                    label="数量">


            </el-table-column>
        </el-table>

    </div>
</template>

<script>
    import {getContractDetail} from "../api/require";

    export default {
        name: "Biao",
        data(){
           return{
               id:'',
               pageData:[],
               tableData:[],
               retailer:{}
           }
        },
        created() {
            // console.log(this.$route.params.id)
            this.id=this.$route.params.id
            this.getPageData()
        },
        methods:{
            getPageData(){
                getContractDetail({contractId:this.id}).then(res=>{
                    if (res.data.code === 200){
                        this.pageData = res.data.obj
                        this.tableData=res.data.obj.commoditiesList
                        this.retailer = res.data.obj.retailer
                    }
                })
            },
        }
    }
</script>

<style scoped lang="scss">
    .container{
        width: 70%;
        padding: 0 30px;
        margin: 0 auto;
        background: #eeeeee;
    }
.colll{
    display: flex;
    flex-direction: column;
}
</style>
